﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_DLL.Product.DAO;
using ERP_RORZE_DLL.Product.Base;

namespace ERP_RORZE_PRODUCT.Product.Machine
{
    public partial class frm_MachineCapacity : DevExpress.XtraEditors.XtraForm
    {
        ClsMachineDAO clsmachineDAO = new ClsMachineDAO();

        public frm_MachineCapacity()
        {
            InitializeComponent();
        }

        private void btnRefreshData_Click(object sender, EventArgs e)
        {
            clsmachineDAO.Dostoreprocedure(clsConstantsFuction.ClsFuctionMachine.PNotFinishTimeAppend );
            clsmachineDAO.Dostoreprocedure(clsConstantsFuction.ClsFuctionMachine.PNotStartTimeAppend);
            MessageBox.Show("Đã cập nhật thành công");
        }

        private void btnView_Click(object sender, EventArgs e)
        {
            if (CheckAll.Checked == true)
            {
                clsmachineDAO.Dostoreprocedure(clsConstantsFuction.ClsFuctionMachine.Capcalculation_Crosstab);
                MessageBox.Show("Đã cập nhật thành công");
            }
            else if (checkCustomer.Checked == true)
            {
                clsmachineDAO.Dostoreprocedure(clsConstantsFuction.ClsFuctionMachine.CapcalculationCustomer_Crosstab);
                MessageBox.Show("Đã cập nhật thành công");
            }
            else if (CheckAll10.Checked == true)
            {
                clsmachineDAO.Dostoreprocedure(clsConstantsFuction.ClsFuctionMachine.Capcalculation_CrosstabTN);
                MessageBox.Show("Đã cập nhật thành công");
            }
            else if (checkCustomer10.Checked == true)
            {
                clsmachineDAO.Dostoreprocedure(clsConstantsFuction.ClsFuctionMachine.CapcalculationCustomer_CrosstabTN);
                MessageBox.Show("Đã cập nhật thành công");
            }
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            DataTable dt;
            if (CheckAll.Checked == true)
            {
                gridView1.PopulateColumns();
                dt = clsmachineDAO.Dostoreprocedure1(clsConstantsFuction.ClsFuctionMachine.Capcalculation_Crosstab);
                gridControl1.DataSource = dt;
                gridView1.BestFitColumns();
                clsConstantsFuction.ExportToExcel(gridView1, 1, true);
            }
            else if (checkCustomer.Checked == true)
            {
                gridView1.PopulateColumns();
                dt = clsmachineDAO.Dostoreprocedure1(clsConstantsFuction.ClsFuctionMachine.CapcalculationCustomer_Crosstab);
                gridControl1.DataSource = dt;
                gridView1.BestFitColumns();
                clsConstantsFuction.ExportToExcel(gridView1, 1, true);
            }
            else if (CheckAll10.Checked == true)
            {
                gridView1.PopulateColumns();
                dt = clsmachineDAO.Dostoreprocedure1(clsConstantsFuction.ClsFuctionMachine.Capcalculation_CrosstabTN);
                gridControl1.DataSource = dt;
                gridView1.BestFitColumns();
                clsConstantsFuction.ExportToExcel(gridView1, 1, true);
            }
            else if (checkCustomer10.Checked == true)
            {
                gridView1.PopulateColumns();
                dt = clsmachineDAO.Dostoreprocedure1(clsConstantsFuction.ClsFuctionMachine.CapcalculationCustomer_CrosstabTN);
                gridControl1.DataSource = dt;
                gridView1.BestFitColumns();
                clsConstantsFuction.ExportToExcel(gridView1, 1, true);
            }
        }
    }
}
